package org.shoukaiseki.test.spring.multiple.datasource

import org.shoukaiseki.test.html.html
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.ResponseBody

@Controller
class IndexController {


    /**
     * 如果主页失效访问不了,则clean之后重新编译
     */
    @ResponseBody
    @RequestMapping(value = "/",produces = ["text/html;charset=UTF-8"])
    fun index(): String {
        var result= html {
            head {
                title { +"测试主页" }
            }
            body {

                br{
                    a(href = "/hello") { +"hello" }
                }

                a(href = "/count") { +"统计条数" }

                br{
                    a(href = "/delall") { +"删除所有" }
                }
                a(href = "/transa1") { +"test_onedb 事务失败" }

                br{
                    a(href = "/transa1a") { +"test_onedb 事务成功" }
                }
                a(href = "/transa1b") { +"test_onedb 使用 test_twodb 事务失败(数据库2开启事务不影响数据库1)" }


                h1 {+"事务注解中只支持一个事务"}
                br{

                    a(href = "/transa12") { +"onedb,twodb 双事务成功" }
                }

                a(href = "/transa12a") { +"onedb,twodb 双事务失败" }

                +"<h5>多数据库事务使用分布式事务管理器</h5> "
                +"<textarea rows='6' cols='80'>"
                +"<dependency>"
                +"\t<groupId>org.springframework.boot</groupId>"
                +"\t<artifactId>spring-boot-starter-jta-atomikos</artifactId>"
                +"</dependency>"
                +"</textarea>"

                h1 { +System.getProperty("java.version") }

            }
        }
        return result.toString()
    }

}

